<?php if($shopCom->ShopSettings['import']): ?>
<div class="tree" id="exe_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'exe')
		{ $class = 'open'; }
		?>
		<li id="exe" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/reload_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=exe">
			Import/Export</a>
            <ul>
                <li id="exe_1" class="leaf">
                <a style="background-image: url(<?php echo SYSICONS_URL; ?>treemenu/import_16.gif);" href="?con=<?php echo $_REQUEST['con']; ?>&list=exe&type=0"><?php echo ucfirst($txt->getWord('product')); ?> - <?php echo ucfirst($txt->getWord('import')); ?></a></li>
                <li id="exe_2" class="leaf">
                <a style="background-image: url(<?php echo SYSICONS_URL; ?>treemenu/import_16.gif);" href="?con=<?php echo $_REQUEST['con']; ?>&list=exe&type=1"><?php echo ucfirst($txt->getWord('product')); ?> - <?php echo ucfirst($txt->getWord('images')); ?></a></li>
            </ul>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shopCom->ShopSettings['shipping']): ?>
<div class="tree" id="shipping_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'shipping')
		{ $class = 'open'; }
		?>
		<li id="shippings" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/folder_pack_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=shipping">
				<?php echo ucfirst($txt->getWord('shipping_methods')); ?></a>
		<?php
        if($shmethods)
        { echo $ShopShipping->getShopShippingMethodsMenuHTML($shmethods); }
        ?>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shopCom->ShopSettings['provider']): ?>
<div class="tree" id="provider_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'provider')
		{ $class = 'open'; }
		?>
		<li id="providers" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/contacts_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=provider">
				<?php echo ucfirst($txt->getWord('providers')); ?> (<?php echo intval(count($shop->getProviders())); ?>)</a>
		<?php  
		if($shop->getProviders())
		{
			if(count($shop->getProviders()) < 51)
			{ echo $shopCom->getShopProvidersMenuHTML(); }
		}
		?>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shopCom->ShopSettings['brand']): ?>
<div class="tree" id="brand_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'brand')
		{ $class = 'open'; }
		?>
		<li id="brands" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/folder_grey_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=brand">
				<?php echo ucfirst($txt->getWord('brands')); ?> (<?php echo intval(count($shop->getBrands())); ?>)</a>
		<?php 
			if($shop->getBrands())
			{
				if(count($shop->getBrands()) < 51)
				{ echo $shopCom->getProductBrandsMenuHTML(); }
			}
		?>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shop->getGlobalSetting('groups')): ?>
<div class="tree" id="group_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'grp')
		{ $class = 'open'; }
		?>
		<li id="groups" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/folder_red_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=grp">
            	<?php echo ucfirst($txt->getWord('productgroups')); ?> (<?php echo intval(count($shop->getGroups())); ?>)</a>
        <?php 
			if(count($shop->getGroups()) < 51)
			{ echo $shopCom->getProductGroupsMenuHTML(); }
		?>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shop->getGlobalSetting('categories')): ?>
<div class="tree" id="cat_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'cat')
		{ $class = 'open'; }
		?>
		<li id="categories" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/folder_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=cat">
            	<?php echo ucfirst($txt->getWord('categories')); ?></a>
		<?php //echo $shopCom->getProductCatsMenuHTML(); ?>
        </li>
    </ul>
</div>
<?php endif; ?>
<?php if($shop->getGlobalSetting('attributes')): ?>
<div class="tree" id="atr_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'attributes')
		{ $class = 'open'; }
		?>
		<li id="attributes" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/folder_green_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=attributes">
            	<?php echo ucfirst($txt->getWord('attributes')); ?></a>
		<?php
        if($attributes)
        { echo $ShopAtt->getShopAttributesMenuHTML($attributes); }
        ?>
        </li>
    </ul>
</div>
<?php endif; ?>
<div class="tree" id="orders_tree">
	<ul style="position:relative; left:-10px;">
    	<?php
		$class = '';
		if($_REQUEST['list'] == 'orders')
		{ $class = 'open'; }
		?>
		<li id="orders" rel="root" class="<?php echo $class; ?>">
        	<a style="background-image:url(<?php echo SYSICONS_URL; ?>treemenu/package_16.gif)" href="?con=<?php echo $_REQUEST['con']; ?>&list=orders">
            	<?php echo ucfirst($txt->getWord('orders')); ?></a>
			<ul>
            	<li class="leaf">
                
                	<a href="?con=<?php echo $_REQUEST['con']; ?>&list=orders&status=1" style="background-image: url(<?php echo SYSICONS_URL; ?>treemenu/package_16.gif);">Nye<?php echo '('.$shop->getOrdersNewCount().')'; ?></a>
                </li>
                <li class="leaf">
                	<a href="?con=<?php echo $_REQUEST['con']; ?>&list=orders&status=2" style="background-image: url(<?php echo SYSICONS_URL; ?>treemenu/package_16.gif);">Under behandling<?php echo '('.$shop->getOrdersPendingCount().')'; ?></a>
                </li>
                <li class="leaf last">
                	<a href="?con=<?php echo $_REQUEST['con']; ?>&list=orders&status=3" style="background-image: url(<?php echo SYSICONS_URL; ?>treemenu/package_16.gif);">Levert<?php echo '('.$shop->getOrdersProcessedCount().')'; ?></a>
                </li>
            </ul>
        </li>
    </ul>
</div>
<div class="tree" id="menu_tree"></div>
<script type="text/javascript">
	function load_tree_menu() 
	{
		var ctrldown = false;
		var exe_down = 0;
		var provider_down = 0;
		var brand_down = 0;
		var group_down = 0;
		var cat_down = 0;
		var atr_down = 0;
		var sec_down = 0;
		
		jQuery.cookie('exe_down', '1', { expires: 1 });
		jQuery.cookie('provider_down', '1', { expires: 1 });
		jQuery.cookie('brand_down', '1', { expires: 1 });
		jQuery.cookie('group_down', '1', { expires: 1 });
		jQuery.cookie('cat_down', '1', { expires: 1 });
		jQuery.cookie('atr_down', '0', { expires: 1 });
		jQuery.cookie('sec_down', '0', { expires: 1 });
		jQuery.cookie('shipping_down', '0', { expires: 1 });
		
		jQuery("#exe_tree").tree(
		{
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_GET['exe'] > 0)
			{ echo 'selected : ["#exe_'.$_GET['exe'].'"],'; }
			?>
			<?php 
			if($_GET['exe'] > 0)
			{ echo 'open : ["#exe_'.$_GET['exe'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('exe_down') != 0)
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('exe_down', '1', { expires: 1 }); }
				}
			}
		});
		
		jQuery("#shipping_tree").tree(
		{
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_GET['shipping'] > 0)
			{ echo 'selected : ["#shipping_'.$_GET['shipping'].'"],'; }
			?>
			<?php 
			if($_GET['shipping'] > 0)
			{ echo 'open : ["#shipping_'.$_GET['shipping'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('shipping_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('shipping_down', '1', { expires: 1 }); }
				}
			}
		});
		<?php if($shopCom->ShopSettings['provider']): ?>
		jQuery("#provider_tree").tree(
		{
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_GET['provider'] > 0)
			{ echo 'selected : ["#provider_'.$_GET['provider'].'"],'; }
			?>
			<?php 
			if($_GET['provider'] > 0)
			{ echo 'open : ["#provider_'.$_GET['provider'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('provider_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('provider_down', '1', { expires: 1 }); }
				},
				onclick : function (NODE) 
				{
					if(jQuery.cookie('provider_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('provider_down', '1', { expires: 1 }); }
				}
			}
		});
		<?php endif; ?>
		<?php if($shopCom->ShopSettings['brands']): ?>
		jQuery("#brand_tree").tree(
		{
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_GET['brand'] > 0)
			{ echo 'selected : ["#brand_'.$_GET['brand'].'"],'; }
			?>
			<?php 
			if($_GET['brand'] > 0)
			{ echo 'open : ["#brand_'.$_GET['brand'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('brand_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('brand_down', '1', { expires: 1 }); }
				}
			}
		});
		<?php endif; ?>
		jQuery("#group_tree").tree(
		{  
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_REQUEST['grp'] > 0)
			{ echo 'selected : ["#grp_'.$_REQUEST['grp'].'"],'; }
			?>
			<?php 
			if($_REQUEST['grp'] > 0)
			{ echo 'open : ["#grp_'.$_REQUEST['grp'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('group_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('group_down', '1', { expires: 1 }); }
				}
			}
		});
		
		jQuery("#atr_tree").tree(
		{  
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_REQUEST['attribute'] > 0)
			{ echo 'selected : ["#atr_'.$_REQUEST['attribute'].'"],'; }
			?>
			<?php 
			if($_REQUEST['attribute'] > 0)
			{ echo 'open : ["#atr_'.$_REQUEST['attribute'].'"],'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('atr_down') != 0)
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('atr_down', '1', { expires: 1 }); }
				}
			}
		});
		
		jQuery("#cat_tree").tree(
		{  
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_REQUEST['cat'] > 0)
			{ echo 'selected : ["#cat_'.$_REQUEST['cat'].'"], '; }

			if($_REQUEST['cat'] > 0)
			{ echo 'open : ["#cat_'.$_REQUEST['cat'].'"] ,'; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('cat_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('cat_down', '1', { expires: 1 }); }
				}
			}
		});
		
		jQuery("#orders_tree").tree(
		{  
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			<?php 
			if($_REQUEST['view'] > 0)
			{ echo 'selected : ["#view_'.$_REQUEST['view'].'"], '; }
			?>
			callback:
			{
				onchange : function (NODE) 
				{
					if(jQuery.cookie('orders_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('orders_down', '1', { expires: 1 }); }
				}
			}
		});
		
		jQuery("#menu_tree").tree(
		{ 
			data : 
			{ 
				type : "json", 
				async : false, 
				url : "ajax.php?con=<?php echo $_GET['con']; ?>&m=<?php echo $_GET['m']; ?>&ajax=menu"
			}, 
			ui: 
			{ 
				animation : 100, 
				dots : true
			},
			rules: 
			{
				draggable : [ "product", "section" ], 
				dragrules : [ "product inside section" , "section inside section", "section inside root" ],
				renameable :[ "product", "section" ],
				creatable : "none",
				drag_copy : "CTRL"
			},
			<?php 
			if($_GET['m'] > 0)
			{ echo ' selected : ["#m_'.$_GET['m'].'"], '; }
			if($_GET['m'] > 0)
			{ echo ' open : ["#m_'.$_GET['m'].'"], '; }
			?>
			callback:
			{
				oncopy : function(NODE,REF_NODE,TYPE,TREE_OBJ) { alert("Node copied"); }, 
				ondblclk : function(NODE) 
				{ 
					//if(jQuery(NODE).attr('rel') == 'product')
					//{ 
						document.location.href = jQuery(NODE).children('a:eq(0)').attr('href'); 
					//} 
				},
				onmove : function(NODE)
				{ 
					document.getElementById('drag_item_id').value = jQuery(NODE).children('a:eq(0)').attr('itemid');
					document.getElementById('drag_item_type').value = jQuery(NODE).attr('rel');
					document.getElementById('drag_from_id').value = jQuery(NODE).children('a:eq(0)').attr('oldparent');
					document.getElementById('drop_item_id').value = jQuery(NODE).parent('ul').parent('li').children('a:eq(0)').attr('itemid');
					document.getElementById('drop_item_type').value = jQuery(NODE).parent('ul').parent('li').attr('rel');
					if (ctrldown)
					{ document.getElementById('ajax_action').value = 'copy'; }
					else
					{ document.getElementById('ajax_action').value = 'move'; }
					//document.getElementById('edit_form').submit();
				},
				onrename : function(NODE) 
				{  
					document.getElementById('edit_item_id').value = jQuery(NODE).children('a:eq(0)').attr('itemid');
					document.getElementById('edit_item_type').value = jQuery(NODE).attr('rel');
					document.getElementById('edit_new_name').value = jQuery(NODE).children('a:eq(0)').text();
					document.getElementById('ajax_action').value = 'rename';
					hc_admin_menu_tree.refresh;
				},
				ondelete : function(NODE) 
				{ 
					document.getElementById('edit_item_id').value = jQuery(NODE).children('a:eq(0)').attr('itemid');
					document.getElementById('edit_item_type').value = jQuery(NODE).attr('rel');
					document.getElementById('ajax_action').value = 'delete';
				},
				onchange : function (NODE) 
				{
					if(jQuery.cookie('sec_down') == '1')
					{ document.location.href = jQuery(NODE).children("a:eq(0)").attr("href"); }
					else
					{ jQuery.cookie('sec_down', '1', { expires: 1 }); }
				}
			}
		});
	}
</script>